package service

import (
	pb "demo_grpc/proto"
	"io"
	"log"
)

type ClientSimpleService struct {
	pb.UnimplementedClientStreamClientServer
}

// RouteList 实现RouteList方法
func (s *ClientSimpleService) RouteList(srv pb.ClientStreamClient_RouteListServer) error {
	for {
		//从流中获取消息
		res, err := srv.Recv()
		if err == io.EOF {
			//发送结果，并关闭
			return srv.SendAndClose(&pb.ClientSimpleResponse{Value: "ok"})
		}
		if err != nil {
			return err
		}
		log.Println(res.StreamData)
	}
}
